﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using SD.Database;

namespace smallDeimos.Game
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int bio = 9;
            int sId = 3;
            ImageMap ImageMap1 = new ImageMap();
            ImageMap1.ImageUrl = @"MapCreator.aspx?sid=3&bio=9";
            List<int[]> systems = Systems .GetAllSystemsFromBioRange(sId, bio);
            //calculate cell size
            int cellW, cellH;
            cellW = MapDrawer.Width / bio;
            cellH = MapDrawer.Height / bio;
            //Response.Write("cellW/H:" + cellW.ToString() + "/" + cellH.ToString() +"<br>");
            int tY = cellH * bio / 2 - cellH/2;
            int tX = cellW * bio / 2- cellW/2;
            //Response.Write("tx/y" + tX.ToString() + "/" + tY.ToString() + "<br>");

            //create rectangle hotspots
            foreach (int[] t in systems)
            {
                RectangleHotSpot s = new RectangleHotSpot();
                s.Top = cellH * t[1] + tY;
                s.Left = cellW * t[0] + tX;
                s.Right = cellW * (t[0] + 1) + tX;
                s.Bottom = cellH * (t[1] + 1) + tY;
                //Response.Write("TL:(" + s.Top.ToString() + "," + s.Left.ToString() + ")<br/>");
                s.NavigateUrl = "SystemView.aspx?sId=" + Systems .SystemAtCoordinates(t[0], t[1]).ToString();
                ImageMap1.HotSpots.Add(s);
            }

            this.Page.Controls.Add(ImageMap1);
        }
    }
}
